import { requireAdmin } from "#server/utils/admin-guard"; import { updateAgentTool } from "#server/service/agent-tool"; export default defineWrappedResponseHandler(async (event) => { await requireAdmin(event); const id = getRouterParam(event, "id"); if (!id) { return R.throwError(400, "无效的工具ID", null); } const body = await readBody(event); const { name, slug, description, type, config, enabled, sortOrder } = body; try { const result = await updateAgentTool(id, { name, slug, description, type, config, enabled, sortOrder, }); if (!result) { return R.throwError(404, "工具不存在", null); } return R.success(result); } catch (e) { return R.throwError(400, e instanceof Error ? e.message : String(e), null); } });